package com.ruoyi.basebill.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.basebill.domain.OmsSumpurinwarehsbill;
import com.ruoyi.basebill.service.IOmsSumpurinwarehsbillService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 汇总采购入库单Controller
 * 
 * @author wenyixiong
 * @date 2023-02-18
 */
@RestController
@RequestMapping("/settlementCenter/basebill/sumpurinwarehsbill")
public class OmsSumpurinwarehsbillController extends BaseController
{
    @Autowired
    private IOmsSumpurinwarehsbillService omsSumpurinwarehsbillService;

    /**
     * 查询汇总采购入库单列表
     */
    @PreAuthorize("@ss.hasPermi('settlementCenter/basebill:sumpurinwarehsbill:list')")
    @GetMapping("/list")
    public TableDataInfo list(OmsSumpurinwarehsbill omsSumpurinwarehsbill)
    {
        startPage();
        List<OmsSumpurinwarehsbill> list = omsSumpurinwarehsbillService.selectOmsSumpurinwarehsbillList(omsSumpurinwarehsbill);
        return getDataTable(list);
    }

    /**
     * 导出汇总采购入库单列表
     */
    @PreAuthorize("@ss.hasPermi('settlementCenter/basebill:sumpurinwarehsbill:export')")
    @Log(title = "汇总采购入库单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OmsSumpurinwarehsbill omsSumpurinwarehsbill)
    {
        List<OmsSumpurinwarehsbill> list = omsSumpurinwarehsbillService.selectOmsSumpurinwarehsbillDetailList(omsSumpurinwarehsbill);
        ExcelUtil<OmsSumpurinwarehsbill> util = new ExcelUtil<OmsSumpurinwarehsbill>(OmsSumpurinwarehsbill.class);
        util.exportExcel(response, list, "汇总采购入库单数据");
    }

    /**
     * 获取汇总采购入库单详细信息
     */
    @PreAuthorize("@ss.hasPermi('settlementCenter/basebill:sumpurinwarehsbill:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(omsSumpurinwarehsbillService.selectOmsSumpurinwarehsbillById(id));
    }

    /**
     * 新增汇总采购入库单
     */
    @PreAuthorize("@ss.hasPermi('settlementCenter/basebill:sumpurinwarehsbill:add')")
    @Log(title = "汇总采购入库单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OmsSumpurinwarehsbill omsSumpurinwarehsbill)
    {
        return toAjax(omsSumpurinwarehsbillService.insertOmsSumpurinwarehsbill(omsSumpurinwarehsbill));
    }

    /**
     * 修改汇总采购入库单
     */
    @PreAuthorize("@ss.hasPermi('settlementCenter/basebill:sumpurinwarehsbill:edit')")
    @Log(title = "汇总采购入库单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OmsSumpurinwarehsbill omsSumpurinwarehsbill)
    {
        return toAjax(omsSumpurinwarehsbillService.updateOmsSumpurinwarehsbill(omsSumpurinwarehsbill));
    }

    /**
     * 删除汇总采购入库单
     */
    @PreAuthorize("@ss.hasPermi('settlementCenter/basebill:sumpurinwarehsbill:remove')")
    @Log(title = "汇总采购入库单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(omsSumpurinwarehsbillService.deleteOmsSumpurinwarehsbillByIds(ids));
    }
}
